package com.findFish.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.findFish.common.annotation.Log;
import com.findFish.common.core.controller.BaseController;
import com.findFish.common.core.domain.AjaxResult;
import com.findFish.common.enums.BusinessType;
import com.findFish.system.domain.RobotFishSensors;
import com.findFish.system.service.IRobotFishSensorsService;
import com.findFish.common.utils.poi.ExcelUtil;
import com.findFish.common.core.page.TableDataInfo;

/**
 * 机器鱼传感器数据Controller
 * 
 * @author admin
 * @date 2025-03-31
 */
@RestController
@RequestMapping("/robot/sensors")
public class RobotFishSensorsController extends BaseController
{
    @Autowired
    private IRobotFishSensorsService robotFishSensorsService;

    /**
     * 查询机器鱼传感器数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:sensors:list')")
    @GetMapping("/list")
    public TableDataInfo list(RobotFishSensors robotFishSensors)
    {
        startPage();
        List<RobotFishSensors> list = robotFishSensorsService.selectRobotFishSensorsList(robotFishSensors);
        return getDataTable(list);
    }

    /**
     * 导出机器鱼传感器数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:sensors:export')")
    @Log(title = "机器鱼传感器数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RobotFishSensors robotFishSensors)
    {
        List<RobotFishSensors> list = robotFishSensorsService.selectRobotFishSensorsList(robotFishSensors);
        ExcelUtil<RobotFishSensors> util = new ExcelUtil<RobotFishSensors>(RobotFishSensors.class);
        util.exportExcel(response, list, "机器鱼传感器数据数据");
    }

    /**
     * 获取机器鱼传感器数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:sensors:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(robotFishSensorsService.selectRobotFishSensorsById(id));
    }

    /**
     * 新增机器鱼传感器数据
     */
    @PreAuthorize("@ss.hasPermi('system:sensors:add')")
    @Log(title = "机器鱼传感器数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RobotFishSensors robotFishSensors)
    {
        return toAjax(robotFishSensorsService.insertRobotFishSensors(robotFishSensors));
    }

    /**
     * 修改机器鱼传感器数据
     */
    @PreAuthorize("@ss.hasPermi('system:sensors:edit')")
    @Log(title = "机器鱼传感器数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RobotFishSensors robotFishSensors)
    {
        return toAjax(robotFishSensorsService.updateRobotFishSensors(robotFishSensors));
    }

    /**
     * 删除机器鱼传感器数据
     */
    @PreAuthorize("@ss.hasPermi('system:sensors:remove')")
    @Log(title = "机器鱼传感器数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(robotFishSensorsService.deleteRobotFishSensorsByIds(ids));
    }
}
